from rest_framework import serializers
from . import models

class BookUnserializer(serializers.Serializer):
    name=serializers.CharField(max_length=32)
    price = serializers.DecimalField(max_digits=9,decimal_places=2)
    desc = serializers.CharField(max_length=1000)
    author_id = serializers.IntegerField()
    img = serializers.ImageField()

    def create(self, validated_data):
        return models.Books.objects.create(**validated_data)



class BookSerializer(serializers.ModelSerializer):
    class Meta:
        model=models.Books
        fields="__all__"